<template>
    <div>
        <el-container>
            <el-header><h1>添加学生信息</h1></el-header>
        </el-container>
        <el-form  label-width="80px">
        <el-form-item label="用户名">
          <el-input
            style="width: 400px"
            placeholder="请输入用户名"
            v-model="stu_name"      
          ></el-input>
        </el-form-item>

        <el-form-item label="密码">
          <el-input
            style="width: 400px"
            placeholder="请输入账户密码"
            v-model="stu_pwd"
          ></el-input>
        </el-form-item>

        <el-form-item label="年龄">
          <el-input
            style="width: 400px"
            placeholder="请输入学生年龄"
            v-model="stu_age"
          ></el-input>
        </el-form-item>

        <el-form-item label="性别">
          <el-input
            style="width: 400px"
            placeholder="请输入学生性别"
            v-model="stu_gender"
          ></el-input>
        </el-form-item>

        <el-form-item label="手机号">
          <el-input
            style="width: 400px"
            placeholder="请输入学生手机号"
            v-model="stu_phone"
          ></el-input>
        </el-form-item>

        <el-form-item label="邮箱">
          <el-input
            style="width: 400px"
            placeholder="请输入学生邮箱"
            v-model="stu_mail"
          ></el-input>
        </el-form-item>

        <el-form-item label="个性签名">
          <el-input
            style="width: 400px"
            placeholder="请输入学生学生个性签名"
            v-model="stu_sign"
          ></el-input>
        </el-form-item> 
        <el-button type="primary" plain style="margin-left:200px" @click="AddDate" >确认添加</el-button>  
      </el-form>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                stu_name: '',
                stu_pwd:'',
                stu_age:'',
                stu_gender:'',
                stu_phone:'',
                stu_mail:'',
                stu_sign:'',
            }
        },
        methods: {
            AddDate() {//添加学生信息
                let stu_name=this.stu_name
                let stu_pwd=this.stu_pwd
                let stu_age=this.stu_age
                let stu_gender=this.stu_gender
                let stu_phone=this.stu_phone
                let stu_mail=this.stu_mail
                let stu_sign=this.stu_sign
                let url = `http://localhost:8080/user/addstudent`;

            const params = `stu_name=${stu_name}&stu_pwd=${stu_pwd}&stu_age=${stu_age}&stu_gender=${stu_gender}&stu_phone=${stu_phone}&stu_mail=${stu_mail}&stu_sign=${stu_sign}`

            this.axios.post(url,params).then((res)=>{
                if(res.data.code==200){
                     this.$message({
                      message: '恭喜你，添加成功',
                      type: 'success'
                  });
                }
            })
            }
        },
    }
</script>

<style lang="scss" scoped>

</style>